package ExceptionDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2025-03-13
 * Time: 20:56
 */
public class Test {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        try {
            System.out.println(arr[10]);//ArrayIndexOutOfBoundsException
            System.out.println(2 / 0);//ArithmeticException
            String s = null;
            System.out.println(s.equals("abc"));//NullPointerException
        }catch (NullPointerException e){
            System.out.println("空指针异常");
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("数组越界异常");
        }catch (ArithmeticException e){
            System.out.println("算术异常");
        }catch (Exception e){
            System.out.println("异常");
        }
        System.out.println("异常后的语句");
    }
}
